package com.栈;

import java.util.Stack;

/**
 * 用栈实现
 */
public class 每日温度2 {
    static  class Solution {

        public int[] dailyTemperatures(int[] T) {
            Stack<Integer> stack = new Stack<>();
            int[] day = new int[T.length];
            int index = 0 ;
            for(int i = 0;i<T.length;i++){
                stack.push(T[i]);
                for(int j = i+1;j<T.length;j++){
                    int tmp = stack.pop();
                    if(tmp<T[j]){
                        day[i] = j-i;
                        break;
                    }
                }
            }

            return day;
        }
        }
}
